<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>盘点计划列表</title>
    <jsp:include page="/WEB-INF/view/commons/css.jsp" />
</head>
<body >
<div id="main-container" class="container-fluid">
    <form action="appCheckPlan/dolist" method="post" name="searchForm" id="searchForm" role="form" class="form-horizontal">
            <div class="form-group">
                    <label class="col-sm-1 control-label">盘点单号：</label>
                    <div class="col-md-4">
                                <input type="text" class="form-control" name="checkCode" value="${entity.checkCode}" placeholder="盘点单号">
                    </div>
                    <label class="col-sm-1 control-label">计划名称：</label>
                    <div class="col-md-4">
                                <input type="text" class="form-control" name="planName" value="${entity.planName}" placeholder="计划名称">
                    </div>
            </div>

            <div class="form-group">
                <label class="col-sm-1 control-label">发起人：</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" name="initiatorName" value="${entity.initiatorName}" placeholder="发起人">
                </div>
                <label class="col-sm-1 control-label">盘点人：</label>
                <div class="col-md-4">
                    <input type="text" class="form-control" name="checker" value="${entity.checker}" placeholder="盘点人">
                </div>
            </div>
        <div class="form-group">
            <label class="col-sm-1 control-label">发起时间：</label>
            <div class="col-md-6">
                <div class="input-group">
                    <input type="text"  class="span1 Wdate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', maxDate:'#F{$dp.$D(\'endTimeStr\')}'})" id="beginTimeStr" name="beginTimeStr" value="${searchEntity.beginTimeStr}" placeholder="开始时间" />
               		至 <input type="text"  class="span1 Wdate" onFocus="WdatePicker({dateFmt:'yyyy-MM-dd', minDate:'#F{$dp.$D(\'beginTimeStr\')}'})" id="endTimeStr" name="endTimeStr" value="${searchEntity.endTimeStr}" placeholder="结束时间" />
                     <button id="searchBtn" type="button" class="btn btn-sm btn-info" style="margin-left:10px;margin-right: 10px;"><i class="fa fa-search"></i> 搜索</button>
                     <button type="button" data-url="appCheckPlan/create" class="btn btn-sm btn-success link_add" data-title="新增盘点计划"><i class="fa fa-plus"></i> 起草 </button>
                </div>
            </div>
        </div>
    </form>
    <table id="table_data" class="table table-striped table-bordered table-hover">
        <thead>
        <tr>
            <th width="10%">盘点单号</th>
            <th width="10%">计划名称</th>
            <th width="10%">发起人姓名</th>
            <th width="10%">发起时间</th>
            <th width="10%">盘点人</th>
            <th width="10%">盘点时间</th>
            <th width="10%">盘点状态</th>
            <th width="10%">操作</th>
        </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
    <i class="ace-icon fa fa-angle-double-up icon-only bigger-110"></i>
</a>
<!-- script start -->
<jsp:include page="/WEB-INF/view/commons/js.jsp" />
<script type="text/javascript">
    $(document).ready(function(e) {
        var table = $("#table_data").dataTable({
            ajax: function(data, callback, settings){
                tableAjax($("#searchForm"),data, callback, settings);
            },
            //列表表头字段
            columns: [
                { "data": "checkCode",name:"check_code",orderable:false  },
                { "data": "planName",name:"plan_name",orderable:false  },
                { "data": "initiatorName",name:"initiator_name",orderable:false  },
                { "data": "initiatorTimeStr",name:"initiator_time" },
                { "data": "checker",name:"checker" ,orderable:false },
                { "data": "checkTimeStr",name:"check_time" },
                { "data": "checkStatusStr",name:"check_status" ,orderable:false },
                {
                    "data": "action",orderable:false,
                    "render": function ( data, type, row, meta ) {
                        var _check = "<a href='javacript:void(0);' onclick=\"handlerShow('"+row.id+"','check')\" >盘点</a>";
                        var info = "<a href='javacript:void(0);' onclick=\"show_in('"+row.id+"')\" >查看</a>"
                        var edit = "<a href='javacript:void(0);' onclick=\"handlerShow('"+row.id+"','edit')\">编辑</a>"
                        var del = "<a href='javacript:void(0);' onclick=\"handlerDelete('"+ row.id +"')\">删除</a>"
                        var sign = "<a href='javacript:void(0);' onclick=\"handlerSign('"+ row.id +"')\">签署</a>"
                        if(row.checkStatus == 3){ return info; }
                        if(row.checkStatus == 2){ return sign; }
                        if(row.checkStatus == 1){ return _check+"&nbsp;&nbsp;"+edit+"&nbsp;&nbsp;"+del; }
                        return "";
                    }
                }
        ]
    }).api();

        //查询条件
        $("#searchForm").submit(function(){
            table.ajax.reload();
            return false;
        });
    });


    //编辑盘点单
    function handlerShow(id,action){
        var option={
            url:"appCheckPlan/edit/"+id+"/"+action,
            title:"编辑盘点单",
            width:$(window).width() + "px",
            height:$(window).height() + "px"
        };
        openIframe(option);
    }

    //签署
    function handlerSign(id){
        var option={
            url:"appCheckPlan/checkSign/"+id,
            title:"签署盘点单",
            width:'60%',
            height:'90%'
        };
        openIframe(option);
    }

    //查看出库单签署过后的文件
    function show_in(id){
        var option={
            url:"appCheckPlan/checkPrintSigned/"+id,
            title:"查看盘点单",
            width:'60%',
            height:'90%'
        };
        openIframe(option);
    }

    // 删除
    function handlerDelete(id){
        layer.confirm("确定要删除此记录吗?", function(index) {
            layer.close(index);
            $.ajax({
                url: "appCheckPlan/delete/" + id,
                type: "DELETE",
                dataType: "json",
                success: function (data) {
                    if(data.success){
                        $('#searchForm').submit();
                    }else{
                        layer.alert(data.msg);
                    }
                }
            });
        });
    }

</script>
<!-- script end -->
</body>
</html>